import subprocess
import logging
from utils import validate_file_path

# 设置日志记录
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def detect_sub(input_file):
    """检测字幕信息"""
    if not validate_file_path(input_file):
        return
    command = f"ffmpeg -i {input_file} 2>&1 | grep 'Subtitle'"
    try:
        result = subprocess.run(command, shell=True, capture_output=True, text=True, check=True)
        logging.info(f"Subtitle information: {result.stdout}")
    except subprocess.CalledProcessError as e:
        logging.error(f"FFmpeg command failed: {e}")
    except Exception as e:
        logging.error(f"An error occurred: {e}")